/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.chrfra.entities;

import java.io.IOException;
import java.io.*;
import java.io.Serializable;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.logging.Level;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.xml.bind.annotation.XmlRootElement;
/**
 *
 * @author EGHOS
 */
@XmlRootElement
@Entity
public class Car implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Column
    private int year_;
    @Column
    private int mileage;
    @Column
    private double price;
    @Column
    private String imagePath;
    @Column
    private String modell;
    @Column
    private String make;
    @Column
    private Boolean sold;

    public Car() {
        sold = false; //all cars are created as not yet sold
    }

    public int getMileage() {
        return mileage;
    }

    public void setMileage(int mileage) {
        this.mileage = mileage;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getYear() {
        return year_;
    }

    public void setYear(int year_) {
        this.year_ = year_;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public String getMake() {
        return make;
    }

    public void setMake(String make) {
        this.make = make;
    }

    public String getModell() {
        return modell;
    }

    public void setModell(String modell) {
        this.modell = modell;
    }

    public Long getId() {
        return id;
    }

    public Boolean getSold() {
        return sold;
    }

    public void setId(Long id) {
        this.id = id;
    }
    /*
    public InputStream getPhotoContent() throws SQLException {
    if (getImage() == null) {
    return null;
    }
    
    return getImage().getBinaryStream();
    }
     */

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Car)) {
            return false;
        }
        Car other = (Car) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.chl.eghogho.Product[ id=" + id + " ]";
    }

}
